package com.lry.basic.spring.aop.test;

import com.lry.basic.spring.aop.face.MethodAroundAdvice;
import com.lry.basic.spring.ioc.anno.Component;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author:刘仁有
 * @desc:
 * @email:953506233@qq.com
 * @data:2019/11/8
 */
@Component
public class MyAroundAdvice implements MethodAroundAdvice {
    @Override
    public Object around(Method method, Object[] args, Object target) {
        System.out.println("around before");
        try {
            Object obj = method.invoke(target,args);

            System.out.println("around after");
            return obj;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return null;
    }
}
